/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.daistatistic.charts;

import org.jfree.data.DomainOrder;
import org.jfree.data.general.DatasetChangeListener;
import org.jfree.data.general.DatasetGroup;
import org.jfree.data.xy.XYDataset;

public class XYDatasetTwoSeriesImpl implements XYDataset {

	// the series name
	protected String seriesName0 = "";

	protected String seriesName1 = "";

	// the x and y values
	double xValues[];

	double yValues0[];

	double yValues1[];

	/**
	 * 
	 * set the series name of the chart
	 * 
	 * @param String
	 *            name
	 */
	public void setSeriesName(String name, int seriesNumber) {
		if (seriesNumber == 0)
			this.seriesName0 = name;
		if (seriesNumber == 1)
			this.seriesName1 = name;
	}

	/**
	 * 
	 * set the y-values of the chart
	 * 
	 * @param double[]
	 *            y
	 */
	public void setYValues(double[] y, int forSeries) {
		if (forSeries == 0)
			this.yValues0 = y;
		if (forSeries == 1)
			this.yValues1 = y;

	}

	/**
	 * 
	 * set the x-values of the chart
	 * 
	 * @param double[]
	 *            x
	 */
	public void setXValues(double[] x) {
		this.xValues = x;
	}

	public DomainOrder getDomainOrder() {
		return DomainOrder.ASCENDING;
	}

	/**
	 * 
	 * returns the item count of the dataset
	 * 
	 * @param int
	 *            arg0, irrelevant: only one series is implemented so we can
	 *            return the length of the value array
	 */
	public int getItemCount(int arg0) {
		if (this.yValues1.length < this.xValues.length)
			return this.yValues1.length;
		else
			return this.xValues.length;
	}

	/**
	 * 
	 * irrelevant: used by jfreechart
	 */
	public Number getX(int arg0, int arg1) {
		return null;
	}

	/**
	 * 
	 * returns the xValue used by jfreechart
	 * 
	 * @param int
	 *            arg0, the serie - we have only one serie so we can directly
	 *            return the value of xValues[arg1]
	 * @param int
	 *            arg1, the wanted value
	 */
	public double getXValue(int arg0, int arg1) {

		return this.xValues[arg1];
	}

	/**
	 * 
	 * irrelevant: used by jfreechart
	 */
	public Number getY(int arg0, int arg1) {
		return null;
	}

	/**
	 * 
	 * returns the yValue used by jfreechart
	 * 
	 * @param int
	 *            arg0, the serie - we have only one serie so we can directly
	 *            return the value of yValues[arg1]
	 * @param int
	 *            arg1, the wanted value
	 */
	public double getYValue(int arg0, int arg1) {
		if (arg0 == 0)
			return this.yValues0[arg1];
		if (arg0 == 1)
			return this.yValues1[arg1];
		return 0;
	}

	/**
	 * 
	 * irrelevant: used by jfreechart
	 */
	public int getSeriesCount() {
		return 2;
	}

	/**
	 * 
	 * returns the series name used by jfreechart
	 * 
	 * @param int
	 *            arg0, the series number - we have only one serie so we can
	 *            directly return the only and one series name
	 */
	public String getSeriesName(int arg0) {
		if (arg0 == 0)
			return this.seriesName0;
		if (arg0 == 1)
			return this.seriesName1;
		return "Error";
	}

	/**
	 * 
	 * irrelevant: not used until now
	 */
	public void addChangeListener(DatasetChangeListener arg0) {

	}

	/**
	 * 
	 * irrelevant: not used until now
	 */
	public void removeChangeListener(DatasetChangeListener arg0) {

	}

	/**
	 * 
	 * irrelevant: not used until now
	 */
	public DatasetGroup getGroup() {
		return null;
	}

	/**
	 * 
	 * irrelevant: not used until now
	 */
	public void setGroup(DatasetGroup arg0) {

	}

}

/**
 * $Log: XYDatasetTwoSeriesImpl.java,v $
 * Revision 1.1.28.3  2006/11/23 09:41:16  endert
 * Added License Note at top of each *.java file.
 *
 * Revision 1.1.28.2  2006/07/31 13:36:31  endert
 * Added Java-Doc to constructors if missing, minor refactorings.
 * Revision 1.1.28.1 2006/07/26 15:28:36
 * endert Formatted Code Revision 1.1 2006/03/13 07:38:33 axle moved from
 * ROOT/src for Maven 2 Buildsystem and Team/Soccerscope separation
 * 
 * Revision 1.3 2006/03/07 12:46:30 endert Merge after refactoring: - New
 * State-Interface: One Method for each action type - Action Bean removed -
 * ActionFactorys for helper methods, States calculate main-Action themselves -
 * formatted code - added State-List in Monitor (Context-Menu of Player) - other
 * smaller stuff
 * 
 * Revision 1.2.2.1 2006/02/25 22:07:10 wetzker formated
 * 
 * Revision 1.2 2006/02/22 16:04:46 endert This is done: - Rebound SoccerScope
 * to Agents (can be added or removed in config-file) - Situations now all
 * extend abstract class Situation - Refactorings: ActionBean _ removed from
 * Attributes - SoccerScope will automatically connect to host given in
 * Start-Call - Trainer uses the same host as soccerscope - Removed unused stuff
 * (old confs, bat, etc.) - Code formatted (good luck when merging) - organized
 * imports - all that i forgot to mention here Revision 1.1 2005/05/15 17:02:06
 * andpaul dataset implementation for two graphs
 * 
 * 
 */
